home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_apache.idb / usr / freeware / apache / include / http_config.h.z / http_config.h
C/C++ Source or Header  |  2001-01-10  |  19KB  |  475 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer. 
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in
  13.  *    the documentation and/or other materials provided with the
  14.  *    distribution.
  15.  *
  16.  * 3. All advertising materials mentioning features or use of this
  17.  *    software must display the following acknowledgment:
  18.  *    "This product includes software developed by the Apache Group
  19.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  20.  *
  21.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  22.  *    endorse or promote products derived from this software without
  23.  *    prior written permission. For written permission, please contact
  24.  *    apache@apache.org.
  25.  *
  26.  * 5. Products derived from this software may not be called "Apache"
  27.  *    nor may "Apache" appear in their names without prior written
  28.  *    permission of the Apache Group.
  29.  *
  30.  * 6. Redistributions of any form whatsoever must retain the following
  31.  *    acknowledgment:
  32.  *    "This product includes software developed by the Apache Group
  33.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  36.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  37.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  38.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  41.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  42.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  43.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  44.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  45.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  46.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Group and was originally based
  51.  * on public domain software written at the National Center for
  52.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  53.  * For more information on the Apache Group and the Apache HTTP server
  54.  * project, please see <http://www.apache.org/>.
  55.  *
  56.  */
  57.  
  58. #ifndef APACHE_HTTP_CONFIG_H
  59. #define APACHE_HTTP_CONFIG_H
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. /*
  66.  * The central data structures around here...
  67.  */
  68.  
  69. /* Command dispatch structures... */
  70.  
  71. /* Note that for all of these except RAW_ARGS, the config routine is
  72.  * passed a freshly allocated string which can be modified or stored
  73.  * or whatever... it's only necessary to do pstrdup() stuff with
  74.  * RAW_ARGS.
  75.  */
  76. enum cmd_how {
  77.     RAW_ARGS,            /* cmd_func parses command line itself */
  78.     TAKE1,            /* one argument only */
  79.     TAKE2,            /* two arguments only */
  80.     ITERATE,            /* one argument, occuring multiple times
  81.                  * (e.g., IndexIgnore)
  82.                  */
  83.     ITERATE2,            /* two arguments, 2nd occurs multiple times
  84.                  * (e.g., AddIcon)
  85.                  */
  86.     FLAG,            /* One of 'On' or 'Off' */
  87.     NO_ARGS,            /* No args at all, e.g. </Directory> */
  88.     TAKE12,            /* one or two arguments */
  89.     TAKE3,            /* three arguments only */
  90.     TAKE23,            /* two or three arguments */
  91.     TAKE123,            /* one, two or three arguments */
  92.     TAKE13            /* one or three arguments */
  93. };
  94.  
  95. typedef struct command_struct {
  96.     const char *name;        /* Name of this command */
  97.     const char *(*func) ();    /* Function invoked */
  98.     void *cmd_data;        /* Extra data, for functions which
  99.                  * implement multiple commands...
  100.                  */
  101.     int req_override;        /* What overrides need to be allowed to
  102.                  * enable this command.
  103.                  */
  104.     enum cmd_how args_how;    /* What the command expects as arguments */
  105.  
  106.     const char *errmsg;        /* 'usage' message, in case of syntax errors */
  107. } command_rec;
  108.  
  109. /* The allowed locations for a configuration directive are the union of
  110.  * those indicated by each set bit in the req_override mask.
  111.  *
  112.  * (req_override & RSRC_CONF)   => *.conf outside <Directory> or <Location>
  113.  * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location>
  114.  * (req_override & OR_AUTHCFG)  => *.conf inside <Directory> or <Location>
  115.  *                                 and .htaccess when AllowOverride AuthConfig
  116.  * (req_override & OR_LIMIT)    => *.conf inside <Directory> or <Location>
  117.  *                                 and .htaccess when AllowOverride Limit
  118.  * (req_override & OR_OPTIONS)  => *.conf anywhere
  119.  *                                 and .htaccess when AllowOverride Options
  120.  * (req_override & OR_FILEINFO) => *.conf anywhere
  121.  *                                 and .htaccess when AllowOverride FileInfo
  122.  * (req_override & OR_INDEXES)  => *.conf anywhere
  123.  *                                 and .htaccess when AllowOverride Indexes
  124.  */
  125. #define OR_NONE 0
  126. #define OR_LIMIT 1
  127. #define OR_OPTIONS 2
  128. #define OR_FILEINFO 4
  129. #define OR_AUTHCFG 8
  130. #define OR_INDEXES 16
  131. #define OR_UNSET 32
  132. #define ACCESS_CONF 64
  133. #define RSRC_CONF 128
  134. #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES)
  135.  
  136. /* This can be returned by a function if they don't wish to handle
  137.  * a command. Make it something not likely someone will actually use
  138.  * as an error code.
  139.  */
  140.  
  141. #define DECLINE_CMD "\a\b"
  142.  
  143. /*
  144.  * This structure is passed to a command which is being invoked,
  145.  * to carry a large variety of miscellaneous data which is all of
  146.  * use to *somebody*...
  147.  */
  148.  
  149. typedef struct {
  150.     void *info;            /* Argument to command from cmd_table */
  151.     int override;        /* Which allow-override bits are set */
  152.     int limited;        /* Which methods are <Limit>ed */
  153.  
  154.     configfile_t *config_file;    /* Config file structure from pcfg_openfile() */
  155.  
  156.     ap_pool *pool;            /* Pool to allocate new storage in */
  157.     struct pool *temp_pool;        /* Pool for scratch memory; persists during
  158.                  * configuration, but wiped before the first
  159.                  * request is served...
  160.                  */
  161.     server_rec *server;        /* Server_rec being configured for */
  162.     char *path;            /* If configuring for a directory,
  163.                  * pathname of that directory.
  164.                  * NOPE!  That's what it meant previous to the
  165.                  * existance of <Files>, <Location> and regex
  166.                  * matching.  Now the only usefulness that can
  167.                  * be derived from this field is whether a command
  168.                  * is being called in a server context (path == NULL)
  169.                  * or being called in a dir context (path != NULL).
  170.                  */
  171.     const command_rec *cmd;    /* configuration command */
  172.     const char *end_token;    /* end token required to end a nested section */
  173.     void *context;        /* per_dir_config vector passed 
  174.                  * to handle_command */
  175. } cmd_parms;
  176.  
  177. /* This structure records the existence of handlers in a module... */
  178.  
  179. typedef struct {
  180.     const char *content_type;    /* MUST be all lower case */
  181.     int (*handler) (request_rec *);
  182. } handler_rec;
  183.  
  184. /*
  185.  * Module structures.  Just about everything is dispatched through
  186.  * these, directly or indirectly (through the command and handler
  187.  * tables).
  188.  */
  189.  
  190. typedef struct module_struct {
  191.     int version;        /* API version, *not* module version;
  192.                  * check that module is compatible with this
  193.                  * version of the server.
  194.                  */
  195.     int minor_version;          /* API minor version. Provides API feature
  196.                                  * milestones. Not checked during module init
  197.                  */
  198.     int module_index;        /* Index to this modules structures in
  199.                  * config vectors.
  200.                  */
  201.  
  202.     const char *name;
  203.     void *dynamic_load_handle;
  204.  
  205.     struct module_struct *next;
  206.  
  207.     unsigned long magic;        /* Magic Cookie to identify a module structure;
  208.                                  * It's mainly important for the DSO facility
  209.                                  * (see also mod_so).
  210.                                  */
  211.  
  212.     /* init() occurs after config parsing, but before any children are
  213.      * forked.
  214.      * Modules should not rely on the order in which create_server_config
  215.      * and create_dir_config are called.
  216.      */
  217. #ifdef ULTRIX_BRAIN_DEATH
  218.     void (*init) ();
  219.     void *(*create_dir_config) ();
  220.     void *(*merge_dir_config) ();
  221.     void *(*create_server_config) ();
  222.     void *(*merge_server_config) ();
  223. #else
  224.     void (*init) (server_rec *, pool *);
  225.     void *(*create_dir_config) (pool *p, char *dir);
  226.     void *(*merge_dir_config) (pool *p, void *base_conf, void *new_conf);
  227.     void *(*create_server_config) (pool *p, server_rec *s);
  228.     void *(*merge_server_config) (pool *p, void *base_conf, void *new_conf);
  229. #endif
  230.  
  231.     const command_rec *cmds;
  232.     const handler_rec *handlers;
  233.  
  234.     /* Hooks for getting into the middle of server ops...
  235.  
  236.      * translate_handler --- translate URI to filename
  237.      * access_checker --- check access by host address, etc.   All of these
  238.      *                    run; if all decline, that's still OK.
  239.      * check_user_id --- get and validate user id from the HTTP request
  240.      * auth_checker --- see if the user (from check_user_id) is OK *here*.
  241.      *                  If all of *these* decline, the request is rejected
  242.      *                  (as a SERVER_ERROR, since the module which was
  243.      *                  supposed to handle this was configured wrong).
  244.      * type_checker --- Determine MIME type of the requested entity;
  245.      *                  sets content_type, _encoding and _language fields.
  246.      * logger --- log a transaction.
  247.      * post_read_request --- run right after read_request or internal_redirect,
  248.      *                  and not run during any subrequests.
  249.      */
  250.  
  251.     int (*translate_handler) (request_rec *);
  252.     int (*ap_check_user_id) (request_rec *);
  253.     int (*auth_checker) (request_rec *);
  254.     int (*access_checker) (request_rec *);
  255.     int (*type_checker) (request_rec *);
  256.     int (*fixer_upper) (request_rec *);
  257.     int (*logger) (request_rec *);
  258.     int (*header_parser) (request_rec *);
  259.  
  260.     /* Regardless of the model the server uses for managing "units of
  261.      * execution", i.e. multi-process, multi-threaded, hybrids of those,
  262.      * there is the concept of a "heavy weight process".  That is, a
  263.      * process with its own memory space, file spaces, etc.  This method,
  264.      * child_init, is called once for each heavy-weight process before
  265.      * any requests are served.  Note that no provision is made yet for
  266.      * initialization per light-weight process (i.e. thread).  The
  267.      * parameters passed here are the same as those passed to the global
  268.      * init method above.
  269.      */
  270. #ifdef ULTRIX_BRAIN_DEATH
  271.     void (*child_init) ();
  272.     void (*child_exit) ();
  273. #else
  274.     void (*child_init) (server_rec *, pool *);
  275.     void (*child_exit) (server_rec *, pool *);
  276. #endif
  277.     int (*post_read_request) (request_rec *);
  278.  
  279. #ifdef EAPI
  280.     /*
  281.      * ANSI C guarantees us that we can at least _extend_ the module structure
  282.      * with additional hooks without the need to change all existing modules.
  283.      * Because: ``If there are fewer initializers in the list than members of
  284.      * the structure, the trailing members are initialized with 0.'' (The C
  285.      * Programming Language, 2nd Ed., A8.7 Initialization). So we just
  286.      * have to put our additional hooks here:
  287.      *
  288.      * add_module: 
  289.      *     Called from within ap_add_module() right after the module structure
  290.      *     was linked into the Apache internal module list.  It is mainly
  291.      *     intended to be used to define configuration defines (<IfDefine>)
  292.      *     which have to be available directly after a LoadModule/AddModule.
  293.      *     Actually this is the earliest possible hook a module can use.
  294.      *
  295.      * remove_module: 
  296.      *     Called from within ap_remove_module() right before the module
  297.      *     structure is kicked out from the Apache internal module list.
  298.      *     Actually this is last possible hook a module can use and exists for
  299.      *     consistency with the add_module hook.
  300.      *
  301.      * rewrite_command:
  302.      *     Called right after a configuration directive line was read and
  303.      *     before it is processed. It is mainly intended to be used for
  304.      *     rewriting directives in order to provide backward compatibility to
  305.      *     old directive variants.
  306.      *
  307.      * new_connection:
  308.      *     Called from within the internal new_connection() function, right
  309.      *     after the conn_rec structure for the new established connection was
  310.      *     created and before Apache starts processing the request with
  311.      *     ap_read_request().  It is mainly intended to be used to setup/run
  312.      *     connection dependent things like sending start headers for
  313.      *     on-the-fly compression, etc.
  314.      *
  315.      * close_connection:
  316.      *     Called from within the Apache dispatching loop just before any
  317.      *     ap_bclose() is performed on the socket connection, but a long time
  318.      *     before any pool cleanups are done for the connection (which can be
  319.      *     too late for some applications).  It is mainly intended to be used
  320.      *     to close/finalize connection dependent things like sending end
  321.      *     headers for on-the-fly compression, etc.
  322.      */
  323. #ifdef ULTRIX_BRAIN_DEATH
  324.     void  (*add_module) ();
  325.     void  (*remove_module) ();
  326.     char *(*rewrite_command) ();
  327.     void  (*new_connection) ();
  328.     void  (*close_connection) ();
  329. #else
  330.     void  (*add_module) (struct module_struct *);
  331.     void  (*remove_module) (struct module_struct *);
  332.     char *(*rewrite_command) (cmd_parms *, void *config, const char *);
  333.     void  (*new_connection) (conn_rec *);
  334.     void  (*close_connection) (conn_rec *);
  335. #endif
  336. #endif /* EAPI */
  337. } module;
  338.  
  339. /* Initializer for the first few module slots, which are only
  340.  * really set up once we start running.  Note that the first two slots
  341.  * provide a version check; this should allow us to deal with changes to
  342.  * the API. The major number should reflect changes to the API handler table
  343.  * itself or removal of functionality. The minor number should reflect
  344.  * additions of functionality to the existing API. (the server can detect
  345.  * an old-format module, and either handle it back-compatibly, or at least
  346.  * signal an error). See src/include/ap_mmn.h for MMN version history.
  347.  */
  348.  
  349. #define STANDARD_MODULE_STUFF    MODULE_MAGIC_NUMBER_MAJOR, \
  350.                 MODULE_MAGIC_NUMBER_MINOR, \
  351.                 -1, \
  352.                 __FILE__, \
  353.                 NULL, \
  354.                 NULL, \
  355.                 MODULE_MAGIC_COOKIE
  356.  
  357. /* Generic accessors for other modules to get at their own module-specific
  358.  * data
  359.  */
  360.  
  361. API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m);
  362. API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val);
  363.  
  364. #define ap_get_module_config(v,m)    \
  365.     (((void **)(v))[(m)->module_index])
  366. #define ap_set_module_config(v,m,val)    \
  367.     ((((void **)(v))[(m)->module_index]) = (val))
  368.  
  369. /* Generic command handling function... */
  370.  
  371. API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *);
  372. API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *);
  373. API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int);
  374. API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *);
  375.  
  376. /* For modules which need to read config files, open logs, etc. ...
  377.  * this returns the fname argument if it begins with '/'; otherwise
  378.  * it relativizes it wrt server_root.
  379.  */
  380.  
  381. API_EXPORT(char *) ap_server_root_relative(pool *p, char *fname);
  382.  
  383. /* Finally, the hook for dynamically loading modules in... */
  384.  
  385. API_EXPORT(void) ap_add_module(module *m);
  386. API_EXPORT(void) ap_remove_module(module *m);
  387. API_EXPORT(void) ap_add_loaded_module(module *mod);
  388. API_EXPORT(void) ap_remove_loaded_module(module *mod);
  389. API_EXPORT(int) ap_add_named_module(const char *name);
  390. API_EXPORT(void) ap_clear_module_list(void);
  391. API_EXPORT(const char *) ap_find_module_name(module *m);
  392. API_EXPORT(module *) ap_find_linked_module(const char *name);
  393.  
  394. /* for implementing subconfigs and customized config files */
  395. API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
  396.  
  397. #ifdef CORE_PRIVATE
  398.  
  399. extern API_VAR_EXPORT module *top_module;
  400.  
  401. extern module *ap_prelinked_modules[];
  402. extern module *ap_preloaded_modules[];
  403. extern API_VAR_EXPORT module **ap_loaded_modules;
  404.  
  405. /* For mod_so.c... */
  406.  
  407. void ap_single_module_configure(pool *p, server_rec *s, module *m);
  408.  
  409. /* For http_main.c... */
  410.  
  411. server_rec *ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name);
  412. void ap_init_modules(pool *p, server_rec *s);
  413. void ap_child_init_modules(pool *p, server_rec *s);
  414. void ap_child_exit_modules(pool *p, server_rec *s);
  415. void ap_setup_prelinked_modules(void);
  416. void ap_show_directives(void);
  417. void ap_show_modules(void);
  418. void ap_cleanup_method_ptrs(void);
  419.  
  420. /* For http_request.c... */
  421.  
  422. void *ap_create_request_config(pool *p);
  423. CORE_EXPORT(void *) ap_create_per_dir_config(pool *p);
  424. void *ap_merge_per_dir_configs(pool *p, void *base, void *new);
  425.  
  426. /* For http_core.c... (<Directory> command and virtual hosts) */
  427.  
  428. int ap_parse_htaccess(void **result, request_rec *r, int override,
  429.         const char *path, const char *access_name);
  430.  
  431. CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname,
  432.                 server_rec *main_server, server_rec **);
  433. void ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp);
  434.  
  435. /* ap_check_cmd_context() definitions: */
  436. API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
  437.  
  438. /* ap_check_cmd_context():              Forbidden in: */
  439. #define  NOT_IN_VIRTUALHOST     0x01 /* <Virtualhost> */
  440. #define  NOT_IN_LIMIT           0x02 /* <Limit> */
  441. #define  NOT_IN_DIRECTORY       0x04 /* <Directory> */
  442. #define  NOT_IN_LOCATION        0x08 /* <Location> */
  443. #define  NOT_IN_FILES           0x10 /* <Files> */
  444. #define  NOT_IN_DIR_LOC_FILE    (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
  445. #define  GLOBAL_ONLY            (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
  446.  
  447.  
  448. /* Module-method dispatchers, also for http_request.c */
  449.  
  450. int ap_translate_name(request_rec *);
  451. int ap_check_access(request_rec *);    /* check access on non-auth basis */
  452. int ap_check_user_id(request_rec *);    /* obtain valid username from client auth */
  453. int ap_check_auth(request_rec *);    /* check (validated) user is authorized here */
  454. int ap_find_types(request_rec *);    /* identify MIME type */
  455. int ap_run_fixups(request_rec *);    /* poke around for other metainfo, etc.... */
  456. int ap_invoke_handler(request_rec *);
  457. int ap_log_transaction(request_rec *r);
  458. int ap_header_parse(request_rec *);
  459. int ap_run_post_read_request(request_rec *);
  460.  
  461. /* for mod_perl */
  462.  
  463. CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds);
  464. CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
  465. CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod);
  466. CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l);
  467.  
  468. #endif
  469.  
  470. #ifdef __cplusplus
  471. }
  472. #endif
  473.  
  474. #endif    /* !APACHE_HTTP_CONFIG_H */
  475.